<!DOCTYPE html>

<!--
  Google HTML5 slide template

  Authors: Luke Mahé (code)
           Marcin Wichary (code and design)
           
           Dominic Mazzoni (browser compatibility)
           Charles Chen (ChromeVox support)

  URL: http://code.google.com/p/dp-svn-tutorial/
-->

<html>
  <head>
    <title>SVN - Introduction</title>

    <meta charset='utf-8'>
    <script
      src='../slides.js'></script>
  </head>
  
  <style>
    /* Your individual styles here, or just use inline styles if that’s
       what you want. */
    
    
  </style>

  <body style='display: none'>

    <section class='slides layout-regular template-default'>
      
      <!-- Your slides (<article>s) go here. Delete or comment out the
           slides below. -->
        
        
      
      <article class='biglogo'>
      </article>

      <article>
        <h1>
          SVN Tutorial
          <br>
          Introduction
        </h1>
        <p>
          Uli Heller
          <br>
          July 23, 2011
        </p>
      </article>
      
      <article>
        <h3>
          Agenda
        </h3>
        <ul>
          <li>Challenges In Software Development
          <li>Subversion As A Single User
          <li>Resolving Conflicts
          <li>Lessons Learned
        </ul>
      </article>

      <article>
        <h3>
          Challenges In Software Development (1/3)
        </h3>
        <ul class="build">
          <li>Assume you are a program developer
          <li>You create source files (*.c or *.java) on your
              local hard disk
          <li>You create a build script (makefile or build.xml)
              to compile your source files
          <li>You deliver compiled versions of the source files to customers
        </ul>
      </article>

      <article>
        <h3>
          Challenges In Software Development (2/3)
        </h3>
        <ul class="build">
          <li>How do you keep your back covered?
              <p>
               <ul>
                <li>Create backup copies
                <li>Leads to lots of backup files (.bak, .old, .bak2, ...)
                <li>Confusing to others
               </ul>
              </p>
          <li>How do you work at multiple places, for example @work and
              @home?
              <p>
               <ul>
                <li>Use an USB stick?
                <li>Use a network drive?
               </ul>
              </p>
          <li>How do you work on multiple machines, for example a
              Windows box and a Linux box?
        </ul>
      </article>

      <article>
        <h3>
          Challenges In Software Development (3/3)
        </h3>
        <ul class="build">
          <li>How do you keep versions for various customers?
              <p>
                Typically, this leads to more copies!
              </p>
          <li>How do you know which version builds on which other version?
              <p>
                Use a good naming scheme for your copies!
              </p>
          <li>How do you deliver a bug fix to a customer?
          <li>How do you deliver all known bug fixes to a customer?
          <li>How do you work in team with other developers?
              <br>You must not overwrite other's changes by accident!
          <li>What about a backup of your source code?
        </ul>
      </article>

      <article>
        <h3>
          Subversion - Single User
        </h3>
        <p>
          For a single user, subversion at first looks like a
          central storage server:
        </p>
        <p>
          <img class='centered' src='images/single_user.png'>
        </p>
        <ul>
          <li>Copy data from a server to your development machine
          <li>Copy data from your development machine to a server
        </ul>
        <p>
          For subversion, there exist countless clients. The command
          line client <code>svn</code> is available on every operating system.
        </p>
        <ul>
          <li>
             <a href="../example-commands/svn-version.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a> ... links to command line examples
          <li>
             <a href="../example-gui/about.png">
                  <object data="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-user-desktop.svg">
                     [link]
                     <embed src="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
             </a> ... links to GUI examples (RabbitVCS)
        </ul>
      </article>

      <article>
        <h3>
          Subversion - Single User Via Internet
        </h3>
        <p>
          <img class='centered' src='images/single_user_internet.png'>
        </p>
        <ul>
          <li>It is very easy to access the subversion server via the
              internet
          <li>Typically, the communication is encrypted and safe
              (thanks to https)
        </ul>
      </article>

      <article>
        <h3>
          Subversion - Single User With Multiple Machines
        </h3>
        <p>
          You can easily access the subversion server
          from multiple machines:
        </p>
        <p>
          <img class='centered' src='images/single_user_many_machines.png'>
        </p>
        <ul>
          <li>Works with multiple development machines
          <li>Works for development machines with different operating systems
        </ul>
      </article>

      <article class="smallerX">
        <h3>
          Subversion - Preparing The Repository
        </h3>
        <ul>
          <li>Ask your administrator to create a new repository
              <p>Be prepared to provide a name for this repository!
                <a href="../example-commands/svnadmin-create.txt">
                  <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-gnome-terminal.svg">
                     [link]
                     <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
                </a>
                <a href="../example-gui/create.png">
                  <object data="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml">
                     <param name="src" value="images/dp-user-desktop.svg">
                     [link]
                     <embed src="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml" />
                  </object>
                </a>
              </p>
          <li>After the creation, you will get an URL for the access
          <li>If the URL doesn't contain the word "trunk", then you'll have to
             <span style="font-size:smaller">
              <p>
               <ul>
                <li>Create the base folders "trunk", "branches" and "tags"
                <li>Use this command:
                    <br><code>svn mkdir -m "Create base folder" ${url}/trunk</code>
                    <br>Replace <code>${url}</code> with the URL of the repo
                <li>Do the same for "branches" and "tags"
                <li>Forget about "branches" and "tags" for now!
               </ul>
              </p>
             </span>
          <li>For now, we always use the "trunk"
        </ul>
        <p>
          <a href="../example-commands/svn-mkdir.txt">
            <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
               <param name="src" value="images/dp-gnome-terminal.svg">
               [link]
               <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
            </object>
          </a>
          <a href="../example-gui/mkdir.png">
            <object data="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml">
               <param name="src" value="images/dp-user-desktop.svg">
               [link]
               <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
            </object>
          </a>
        </p>
      </article>

      <article>
        <h3>
          Subversion - Populating The Repository
        </h3>
        <p>
          <img class='centered' src='images/svn_import.png'>
        </p>
        <ul>
          <li>Copy all your source files into one temporary folder
          <li>Go to this temporary folder
          <li>Verify: There are no temporary files that shouldn't go into the repo
          <li>Import the folder into the subversion repository:<br>
              <code>svn import -m "Initial import" ${url}/trunk</code>
              <span style="font-size:smaller; line-height:60%">
               <br>Replace <code>${url}</code> with the URL of the repo
              </span>
          <li>Delete the temporary folder
        </ul>
        <p>
          <a href="../example-commands/svn-import.txt">
            <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
               <param name="src" value="images/dp-gnome-terminal.svg">
               [link]
               <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
            </object>
          </a>
        </p>
      </article>

      <article>
        <h3>
          Subversion - First Checkout
        </h3>
        <p>
          <img class='centered' src='images/svn_first_checkout.png'>
        </p>
        <ul>
          <li>In order to "connect" your local files to the repo, you have to do a first checkout!
          <li>Go to your work area: <code>cd ~/svn</code>
          <li>Checkout the repository<br>
              <code>svn checkout ${url}/trunk ${name}</code>
              <span style="font-size:smaller; line-height:60%">
               <br>Replace <code>${url}</code> with the URL of the repo
               <br>Replace <code>${name}</code> with the name of the repo
              </span>
          <li>Verify: All required files are there<br>
        </ul>
        <p>
          <a href="../example-commands/svn-checkout.txt">
            <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
               <param name="src" value="images/dp-gnome-terminal.svg">
               [link]
               <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
            </object>
          </a>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Single User - Workflow
        </h3>
        <p>
         As a single user on a single machine, you'll probably follow this workflow:
        </p>
        <ul class="build">
          <li>You do all your work within the checkout folder
          <li>For all the files and folders you add, you execute
            <br><code>svn add ${name}</code>
          <li>For all the files and folders you delete, you execute
            <br><code>svn rm ${name}</code>
          <li>You verify your changes by executing
            <ul>
             <li><code>svn status</code>
             <li><code>svn diff</code>
            </ul>
          <li>Frequently, you copy your changes to the repo by executing
            <br><code>svn commit -m "A good description of the changes"</code>
        </ul>
        <p class="build">
          <a href="../example-commands/svn-workflow.txt">
            <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
               <param name="src" value="images/dp-gnome-terminal.svg">
               [link]
               <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
            </object>
          </a>
        </p>
      </article>

      <article>
        <h3>
          Subversion - Repo Contents After A Few Weeks
        </h3>
        <p>
         If you follow the workflow, after a few weeks the repo
         will look like this:
        </p>
        <p>
          <img class='centered' src='images/svn_repo_weeks.png'>
        </p>
        <p>
         In the repo, you have
        </p>
        <ul>
         <li>All of your current files and folders (8)
         <li>The initial import of your files and folders (1)
         <li>All versions in between (2, 3, ..., 7)
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Working With Versions
        </h3>
        <p>
          <img class='centered' src='images/svn_repo_weeks.png'>
        </p>
        <ul>
         <li>Show complete history:
           <br><code>svn log .</code>
            <a href="../example-commands/svn-log.txt">
              <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
              </object>
            </a>
            <a href="../example-gui/svn-log.png">
              <object data="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-user-desktop.svg">
                 [link]
                 <embed src="images/dp-user-desktop.svg" width="30" height="30" type="image/svg+xml" />
              </object>
            </a>
         <li>Checkout an old version by revision number:
           <br><code>svn checkout -r4 ${url}/trunk ${name}_r4</code>
            <a href="../example-commands/svn-checkout-r4.txt">
              <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
              </object>
            </a>
         <li>Checkout an old version by date:
           <br><code>svn checkout -r"{2011-05-06}" ${url}/trunk ${name}_2011-05-06</code>
            <a href="../example-commands/svn-checkout-r20110725.txt">
              <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
              </object>
            </a>
         <li>Show differences between revision numbers:
           <br><code>svn diff -r4:5 ${url}/trunk</code>
            <a href="../example-commands/svn-diff-r45.txt">
              <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
              </object>
            </a>
         <li>Show differences between dates:
           <br><code>svn diff -r"{2011-05-06}:{2011-05-18}" ${url}/trunk</code>
            <a href="../example-commands/svn-diff-r20110724-25.txt">
              <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
              </object>
            </a>
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Single User - Potential Issues
        </h3>
        <p>
         As a single user on a single machine, these are potential issues:
        </p>
        <ul class="build">
          <li>You don't commit your changes to the svn repo
             <br>Solution: Commit as often as you can!
          <li>You remove files/folders from your local folder and forget
              to update the repo accordingly
             <br>Solution: Double-check with <code>svn status</code> (!)
          <li>You add files/folders from your local folder and forget
              to update the repo accordingly
             <br>Solution: Double-check with <code>svn status</code> (?)
          <li>You don't provide good descriptions for your svn commits
             <br>Solution: None!
        </ul>
        <p class="build">
          <a href="../example-commands/svn-issues.txt">
            <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
              <param name="src" value="images/dp-gnome-terminal.svg">
              [link]
              <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
            </object>
          </a>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Working With Multiple Machines
        </h3>
        <p>
          <img class='centered' src='images/svn_multi.png'>
          Sometimes, you have to work with multiple development machines,
          for example with a Linux box and a MacOSX box:
        <ul>
         <li>At start, you copy the repo to both machines by
           <br><code>svn checkout ${url}/trunk ${name}</code>
             or
             <code>svn update</code>
         <li>Then you work on one box or the other
         <li>Before you start to work, you update your local folder and execute
           <br><code>svn update</code>
         <li>After you finished to work, you commit your changes and execute
           <br><code>svn commit -m "Description of the changes"</code>
        </ul>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Multiple Machines - Potential Issues
        </h3>
        <p>
         As a single user on a multiple machines, these are
         additional potential issues:
        </p>
        <ul>
          <li>You forget to update your local repository before the changes
             <br>Solution: Execute <code>svn update</code> as soon as you can!
          <li>You completely forget about the update
             <br>Solution: Typically, you'll see a reminder on <code>svn commit</code>!
             <a href="../example-commands/svn-commit-forgotten-update.txt">
               <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
               </object>
             </a>
          <li>The output of <code>svn update</code> looks strange!
             <br>Solution: You probably have a conflict, you need to resolve it!
             <br>Note: Do not call this a merge!
             <a href="../example-commands/svn-conflict.txt">
               <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
               </object>
             </a>
          <li>You forget to commit your changes
             <br>Solution: Execute <code>svn commit</code> as soon as you can!
             <br>Note: On the other machine, you'll have to follow the 
                 "forgotten update" description afterwards
          <li>You make the same changes on both machines
             <br>Solution: Almost nothing to do - works perfectly
             <a href="../example-commands/svn-same-change.txt">
               <object data="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml">
                 <param name="src" value="images/dp-gnome-terminal.svg">
                 [link]
                 <embed src="images/dp-gnome-terminal.svg" width="30" height="30" type="image/svg+xml" />
               </object>
             </a>
          <li>You make almost the same changes on both machines
             <br>Solution: You'll get a conflict and have to resolve it!
        </ul>
        <p>
           Rule of thumb: Always execute <code>svn update</code>
           before you start working and <code>svn commit</code> when you're
           done!
        </p>
      </article>

      <article>
        <h3>
          Subversion - Multiple Developers
        </h3>
        <ul>
          <li>Often, multiple developers do work on a project
              in parallel
          <li>Potential issues are similar to the multiple machines scenario
          <li>The likelyhood of conflicting modifications is much higher
          <li>Always execute <code>svn update</code> before starting any
              modifications (reduces the likelyhood of conflicts)
          <li>The one who commits first has the easy path
          <li>The one who commits later has to resolve the conflict
          <li>So execute <code>svn commit</code> as soon as possible
        </ul>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Multiple Developers - Conflicts
        </h3>
        <p>
          <img class='centered' src='images/svn_multi_conflict.png'>
        </p>
        <ul>
         <li>Ben starts working
         <li>At first, he gets the current version: <code>svn update</code> (8)
         <li>He modifies it and commits it: <code>svn commit ...</code> (8' and 9)
         <li>The next day, he continues to work (8')
         <li>He modifies it and tries to commit it (8'')
         <li>On commit, he gets an "out of date" error so he has to
             get the current version, resolve the conflicts and
             try to commit again (10', 11)
        </ul>
        </p>
      </article>

      <article class="smaller">
        <h3>
          Subversion - Properties
        </h3>
        <p>
          Properties define attributes
          of files and folders stored in subversion:
        </p>
        <ul>
          <li>List their names with <code>svn proplist</code>
          <li>Show their values with <code>svn propget</code>
          <li>Set their values with <code>svn propset</code>
        </ul>
        <p>
          Examples:
        </p>
        <ul>
          <li>svn:eol-style  ... defines the line separators (Windows - Unix)
          <li>svn:executable ... make shell scripts executable
          <li>svn:ignore ... defines filenames to be ignored by svn
          <li>svn:keywords ... replace certain strings within files
        </ul>
      </article>

      <article>
        <h3>
          Subversion - Lessons Learned
        </h3>
        <ul>
          <li>Checkout, Update
          <li>Status
          <li>Commit
          <li>Conflict - What is it? Why? How to handle?
          <li>Log (version history)
          <li>Diff
          <li>Import, Export
          <li>Properties
        </ul>
      </article>
    </section>

  </body>
</html>
